﻿<?php

//////////////////////////////////////////////////////////////////////////
//
// WikiHiero2 - A PHP convert from text using "Manual for the encoding of
// hieroglyphic texts for computer input" syntax to HTML entities (table and
// images).
//
// Copyright (C) 2004-2007 Guillaume Blanchard (Aoineko)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
//////////////////////////////////////////////////////////////////////////

define("WH_CLASS_DOC",        0);   // <doc>
define("WH_CLASS_HEADER",     1);   // <header>
define("WH_CLASS_AUTHOR",     2);   // <author>
define("WH_CLASS_DATE",       3);   // <date>
define("WH_CLASS_BIBLIO",     4);   // <biblio>
define("WH_CLASS_REFERENCE",  5);   // <reference>
//---------- SPACE DIVISION ----------
define("WH_CLASS_AREA",       100); //   <area level='1' type='register/page/...' name='1'> // nestable
define("WH_CLASS_LINE",       101); //     <line direction='Horizontal/Vertical'>
define("WH_CLASS_LAYOUT",     102); //
define("WH_CLASS_HIEROGLYPH", 103); //        <hiero code='A1' phoneme='Htp' />
define("WH_CLASS_FRAME",      104); //        <cartouche>
define("WH_CLASS_GROUP",      105); //        <group op=':'><hiero/>
define("WH_CLASS_TYPO",       106); //
//---------- SYNTAX DIVISION ----------
define("WH_CLASS_SYNTAX",     200); //   [syntax]
define("WH_CLASS_SECTION",    201); //     <section level='1' type='chapter/paragraph/...' name='' content='Hieroglyph/Comment/Transcription/...'> // nestable
define("WH_CLASS_SENTENCE",   202); //         <sentence>
define("WH_CLASS_WORD",       203); //           <word>
define("WH_CLASS_LEXEME",     204); //             <lexeme type='radix/prefix/suffix/...'>
//---------- SPECIAL TAG ----------
define("WH_CLASS_DESC",       300); //   <desc xlm::lang='fr/en/ja/...' type='title/comment/traduction/...'>
define("WH_CLASS_LOCALIZE",   301); //     <localization xlm::lang='fr/en/ja/...'>

$wh_class = array(
	WH_CLASS_DOC => array( 
		"Tag"            => "doc",
		"Owners"         => array(),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_HEADER => array( 
		"Tag"            => "header",
		"Owners"         => array(WH_CLASS_DOC),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_AUTHOR => array( 
		"Tag"            => "author",
		"Owners"         => array(WH_CLASS_HEADER),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_DATE => array( 
		"Tag"            => "date",
		"Owners"         => array(WH_CLASS_HEADER),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_BIBLIO => array( 
		"Tag"            => "biblio",
		"Owners"         => array(WH_CLASS_HEADER),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_REFERENCE => array( 
		"Tag"            => "reference",
		"Owners"         => array(WH_CLASS_BIBLIO),
		"RequiredParams" => array("title"),
		"OptionalParams" => array("xml:lang", "name", "author", "title", "publisher", "address", "year"), ),
	WH_CLASS_AREA => array( 
		"Tag"            => "area",
		"Owners"         => array(WH_CLASS_DOC, WH_CLASS_AREA),
		"RequiredParams" => array("level"),
		"OptionalParams" => array("type", "name", "pos", "size"), ),
	WH_CLASS_LINE => array( 
		"Tag"            => "line",
		"Owners"         => array(WH_CLASS_AREA),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_LAYOUT => array( 
		"Tag"            => "layout",
		"Owners"         => array(WH_CLASS_LINE, WH_CLASS_LAYOUT),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_FRAME => array( 
		"Tag"            => "frame",
		"Owners"         => array(WH_CLASS_LINE),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_GROUP => array( 
		"Tag"            => "group",
		"Owners"         => array(WH_CLASS_LINE),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_TYPO => array( 
		"Tag"            => "typo",
		"Owners"         => array(WH_CLASS_LINE),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_HIEROGLYPH => array( 
		"Tag"            => "hiero",
		"Owners"         => array(WH_CLASS_LINE, WH_CLASS_LAYOUT, WH_CLASS_FRAME, WH_CLASS_GROUP, WH_CLASS_TYPO),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_SYNTAX => array( 
		"Tag"            => "syntax",
		"Owners"         => array(WH_CLASS_DOC),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_SECTION => array( 
		"Tag"            => "section",
		"Owners"         => array(WH_CLASS_SYNTAX, WH_CLASS_SECTION),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_SENTENCE => array( 
		"Tag"            => "sentence",
		"Owners"         => array(WH_CLASS_SECTION),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_WORD => array( 
		"Tag"            => "word",
		"Owners"         => array(WH_CLASS_SENTENCE),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_LEXEME => array( 
		"Tag"            => "lexeme",
		"Owners"         => array(WH_CLASS_WORD),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
	WH_CLASS_DESC => array( 
		"Tag"            => "desc",
		"Owners"         => array(WH_CLASS_HIEROGLYPH),
		"RequiredParams" => array(),
		"OptionalParams" => array(), ),
);

function WH_GetClassName($classId)
{
	global $wh_class;
	if(!isset($wh_class[$classId]))
		return "invalid";
	return $wh_class[$classId]["Tag"];
}

?>